<?php
require_once 'include.php';
check_login();
?>
<!DOCTYPE html>
<html>
<head>
    <?php include_once 'common_js_css.php'?>
    <link rel="stylesheet" type="text/css" href="css/adfabu.css">
</head>
<body>
<div class="cont" style="height: 730px">
    <h1 style="text-align: center;">发布公告</h1>
    <form id="form1" style="margin-left: 250px;margin-top: 40px">
      <table width="600"  align="center" cellspacing="0">
        <tr>
          <td width="80" height="60" >是否发布</td>
          <td width="254" height="30">
              <select name="kejian" id="status">
                  <option value="1" >发布</option>
                  <option value="2">隐藏</option>
              </select>
          </td>
        </tr>
        <tr>
          <td height="30" align="center">内容</td>
          <td height="30"><label for="cont"></label><textarea name="cont" rows="5" id="content"></textarea></td>
        </tr>
        <tr>
            <td colspan="2" align="center" height="50">
                <input type="button" name="fabu" value="发布" onclick="gonggao()">
            </td>
        </tr>
      </table>
    </form>
    <p style="text-align: center;">&nbsp;</p>
</div>
<script>
    function gonggao() {
        var status = $("#status").val(),
            content = $("#content").val();
        if (status==''||status==null){
            $("#status").after("<span id='titles' style='color: red'>标题不能为空</span>");
        }if(content =='' || content ==null){
            $("#content").after("<span id='contents' style='color: red'>内容不能为空</span>");
        }else {
            post_data={
                status:status,
                content:content
            };
            $.post('doAction.php?act=add_gonggao',post_data,function (data) {
                if (data==200){
                    alert('发布成功，即将跳转公告列表');
                    window.location = 'adlist_gonggao.php';
                }else {
                    alert('发布失败，请重新发布');
                }
            })
        }
    }
</script>
</body>
</html>